<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
class bandaHorariaModel extends CI_Model {

    function __construct() {
        // Call the Model constructor
        parent::__construct();
    }
    
    public function getAll(){
         $query = $this->db->get('profesores_bandas_horarias');
        return $query->result();
    }
    
    public function getByProfesor($profesorId){
        $this->db->where('profesor', $profesorId);
        //here we select every clolumn of the table
        $q = $this->db->get('profesores_bandas_horarias');
        return $q->result();
    }
    
    public function crear($idProfesor,$desde,$hasta,$dia){
        $sql = "INSERT INTO profesores_bandas_horarias (profesor,desde,hasta,dia) 
        VALUES ($idProfesor, '$desde','$hasta', $dia)";

        $this->db->query($sql);
        if($this->db->affected_rows() > 0){
            return $this->db->insert_id();
        }else{
            return $this->db->affected_rows();
        }
    }
    
    public function delete ($bandaId){
        $this->db->where('id', $bandaId);
        $this->db->delete('profesores_bandas_horarias'); 
    }
    

}

